<template>
  <el-row>
    <el-col :span="24" class="bg2">
      <FilterTable
        ref="table"
        selectionType="single"
        :columns="columns"
        columnsRef="yxqNewaddpjxmTable"
        :isColumnFilter="false"
        :onRowSelectChange="arr => (this.onChangeColumn = arr)"
        :onColumnsChange="columns => (this.columns = columns)"
      >
      </FilterTable>
    </el-col>
    <el-col :span="24" style="margin-top:10px;">
      <div class="btn">
        <el-button size="small" icon="el-icon-folder-add" type="primary" class="btnStyle" @click="query">确定</el-button>
        <el-button size="small" icon="el-icon-refresh-left" type="primary" class="btnStyle" @click="closeDialog">取消</el-button>
      </div>
    </el-col>
  </el-row>
</template>

<script>
import { getNewAddPjxm } from '@/api/repair/repair/activitesManage';
import { dictionary } from '@/utils/dictMixin';
export default {
  name: 'newAddPjxm',
  components: {},
  mixins: [dictionary],
  data() {
    return {
      columns: this.createTableColumns(),
      visibleCxz: false,
      onChangeColumn: []
    };
  },
  mounted() {
    this.getNewAddPjxm();
  },
  methods: {
    validateFn(rule, value, callback) {
      if (value.length < rule.limit) {
        return callback(new Error(rule.message));
      }
      callback();
    },
    async getNewAddPjxm() {
      let res = {};
      res = await getNewAddPjxm();
      console.log(res.data, '备件车系');
      this.$refs.table.$refs.pageTable.EXECUTE_INSERT(res.data);
    },
    query() {
      if (this.onChangeColumn.length != 1) {
        this.$notify.error({
          title: '错误',
          message: '请选择一条内容'
        });
      } else {
        this.$emit('closePjxm', this.onChangeColumn);
      }
    },
    closeDialog() {
      this.$emit('closePjxm', false);
    },
    createTableColumns() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '备件车系代码',
          dataIndex: 'PART_MODEL_GROUP_CODE',
          sorter: true
        },
        {
          title: '备件车系名称',
          dataIndex: 'PART_MODEL_GROUP_NAME',
          sorter: true
        }
      ];
    }
  }
};
</script>

<style scoped lang="less">
.bg1 {
  border: 1px solid @borderColor;
  border-radius: @borderRadius;
  box-shadow: @boxShadow;
  padding: @modulePadding;
  padding-left: 0;
  padding-top: 15px;
  padding-bottom: 15px;
}
.bg2 {
  margin-top: 10px;
  margin-bottom: 10px;
}
.btn {
  text-align: center;
}
.btnStyle {
  margin-top: 10px;
}
</style>
